package com.ruoyi.user.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.user.domain.AppRoleMenu;
import com.ruoyi.user.domain.AppUserRole;
import com.ruoyi.user.service.AppRoleMenuService;
import com.ruoyi.user.service.AppUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/menu")
public class AppRoleMenuController {
    @Autowired
    private AppRoleMenuService appRoleMenuService;

    @GetMapping("/get/{roleId}")
    public AjaxResult getMenuRole(@PathVariable("roleId") Integer roleId){
        return AjaxResult.success(appRoleMenuService.getAppRoleMenu(roleId));
    }

    @PostMapping("/add")
    public AjaxResult addUserRole(@RequestBody AppRoleMenu appRoleMenu){
        return AjaxResult.success(appRoleMenuService.addAppRoleMenu(appRoleMenu));
    }

    @DeleteMapping("/remove/{roleId}")
    public AjaxResult removeUserRole(@PathVariable("roleId") Integer roleId){
        return AjaxResult.success(appRoleMenuService.removeAppRoleMenu(roleId));
    }

    @PutMapping("/edit")
    public AjaxResult editUserRole(@RequestBody AppRoleMenu appRoleMenu){
        return AjaxResult.success(appRoleMenuService.editAppRoleMenu(appRoleMenu));
    }
}
